(() => {
	let ele = {}

	// 夺宝规则
	ele.rule = $('#rule')
	ele.modal_tips = $('#modal-tips')
	ele.tips_close = $('#tips-close')
	// 打开夺宝规则
	ele.rule.onclick = () => {
		ele.modal_tips.style.display = 'block'
	}
	// 关闭夺宝规则
	ele.tips_close.onclick = () => {
		ele.modal_tips.style.display = 'none'
	}

	// 夺宝攻略
	ele.modal_binding = $('#modal-binding')
	ele.introduction = $('#introduction')
	ele.binding_close = $('#binding-close')
	// 打开弹框
	ele.introduction.onclick = () => {
		ele.modal_binding.style.display = 'block'
	}
	ele.binding_close.onclick = () => {
		ele.modal_binding.style.display = 'none'
	}

	// for (let i = 0; i < numList.length; i++) {
	// 	let s = w / numList[i]//每一原石所对应的宽度
	// 	ele.timeload[i].style.width = s * (numList[i] - joinNum[i].nums) + "px";//对应列表项的进度
	// 	ele.residue[i].innerText = joinNum[i].nums   //剩余原石数量
	// 	ele.term[i].innerHTML = joinNum[i].remark //第几期
	// }

	// 晶石兑换
	ele.exchange = $('#exchange')
	ele.shengyu = $('#shengyu')
	ele.modal_exchange = $('#modal-exchange')
	ele.enternum = $('#enternum')
	ele.exchange_close = $('#exchange-close')
	ele.exchange_confirm = $('#exchange-confirm')
	ele.exchange.onclick = () => {
		ele.modal_exchange.style.display = 'block'
	}
	ele.exchange_close.onclick = () => {
		ele.modal_exchange.style.display = 'none'
	}

	// 确定兑换
	ele.exchange_confirm.onclick = () => {
		let enternum = ele.enternum.value
		if (!enternum) {
			openTips('请输入数量')
			return
		}
		if (enternum < 100) {
			openTips('每次最低兑换为100')
			return
		}
		if (!/^\d{1,}$/.test(enternum)) {
			openTips('兑换数量只能为整数')
			return
		}

		// let token = getCookie("token");
		// let userid = getCookie("userid");
		// ajax({
		//     url: API_PATH.ZHITUISEARCH,
		//     method: 'POST',
		//     header: {
		//         Authorization: token
		//     },
		//     data: {
		//         invite_code: ID
		//     },
		//     success: res => {
		//         if (res.code == 1) {
		//             drawFriendList(res.data)
		//         } else openTips(res.msg);
		//     }
		// });
	}

	ele.duobao = $('.duobao')
	for (let i = 0; i < ele.duobao.length; i++) {
		ele.duobao[i].onclick = () => {
			location.href = 'seizeTreasures.html?id=' + (i + 1)
		}
	}

})();